package tugas.akhir.jason;

import java.text.SimpleDateFormat;
import java.util.Date;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.widget.Button;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

public class dr02_kantor extends Activity implements OnItemSelectedListener{
	Button next_button2;
	EditText alamat=null;
	EditText namakantor=null;
	EditText alamatkantor=null;
	EditText namapemilik=null;
	EditText nomorkontakpemilik=null;
	String almagId=null;
	private String fIdLaporan, labelId;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dr02_kantor);
		
		alamat=(EditText)findViewById(R.id.dr1_alamat);

		TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
        variabelstatis.imeii = telephonyManager.getDeviceId();
		
		 //tanggal
        SimpleDateFormat sdf = new SimpleDateFormat ("ddMMyy-HHmm");
        fIdLaporan =  "" + variabelstatis.imeii + "-" + sdf.format (new Date ());
        
        variabelstatis.timestamp = "" + sdf.format (new Date ());
        
        TextView rid = (TextView) findViewById (R.id.dr1_reportid_label);
        labelId = "ID Laporan: "  + fIdLaporan;
        rid.setText (labelId);
		
        variabelstatis.idglobal = fIdLaporan;
		
        Spinner spinner = (Spinner) findViewById(R.id.dr02_jumlahpenghuni);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                this, R.array.array2, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new dr02_kantor());
        
		next_button2 = (Button) findViewById(R.id.next_button2);
		next_button2.setOnClickListener(onSave);}
		

	
	private View.OnClickListener onSave=new View.OnClickListener() {
		public void onClick(View v) {
			alamat=(EditText)findViewById(R.id.dr1_alamat);
			namakantor=(EditText)findViewById(R.id.dr02_namakantor);
			variabelstatis.dr02_namakantor = (namakantor.getText().toString());
			
			alamatkantor=(EditText)findViewById(R.id.dr02_alamatkantor);
			variabelstatis.dr02_alamatkantor = (alamatkantor.getText().toString());
			
			namapemilik=(EditText)findViewById(R.id.namapemilikkantor);
			variabelstatis.dr02_namapemilik = (namapemilik.getText().toString());
			
			nomorkontakpemilik=(EditText)findViewById(R.id.nomorkontakpemilik);
			variabelstatis.dr02_nomorkontakpemilik = (nomorkontakpemilik.getText().toString());
			
			variabelstatis.headerdata = "" + variabelstatis.timestamp + " - " + variabelstatis.dr02_namakantor;
			variabelstatis.jenisbangunan = "kantor";

			{ startActivity(new Intent(dr02_kantor.this,dr4_penyebabkerusakan.class)); }
			
		}
	};

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
	// TODO Auto-generated method stub
	variabelstatis.dr02_jumlahlantairusak = arg0.getItemAtPosition(arg2).toString();
}




public void onNothingSelected(AdapterView<?> arg0) {
	// TODO Auto-generated method stub
	
}
}